package com.xmy.cultivate.schedule;

import com.xmy.cultivate.service.IOrderDetailService;
import com.xmy.cultivate.service.IRecordCourseService;
import com.xmy.cultivate.util.SpringUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 课程顺延（已调整到后台）
 */
public class CourseAutoJob implements Job {

    //@Autowired
    //IOrderDetailService iOrderDetailService = SpringUtils.getBean(IOrderDetailService.class);
    @Autowired
    IRecordCourseService iRecordCourseService = SpringUtils.getBean(IRecordCourseService.class);

    private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    private void before() {
        System.out.println("课程顺延任务1：开始执行-" + dateFormat.format(new Date()));
    }

    @Override
    public void execute(JobExecutionContext arg0) throws JobExecutionException {
        before();
        //System.out.println("课程顺延任务1：业务逻辑。。。");
        //iRecordCourseService = (IRecordCourseService) SpringContextJobUtil.getBean("iRecordCourseService");
        //iOrderDetailService.courseAuto();
        //暂时作用消课问题处理
        iRecordCourseService.autoRecordAction2();

        after();
    }

    private void after() {
        System.out.println("课程顺延任务1：执行结束");
        System.out.println();
    }
}
